package com.ricecoder.spring02.service;

import com.ricecoder.spring02.mapper.UserMapper;
import com.ricecoder.spring02.pojo.User;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
//注解声明为Serivce
@Service
public class UserService implements UserMapper {

    @Autowired  //直接输入mapper类
    UserMapper userMapper;

    @Override  //重写接口方法，查询所有用户
    public List<User> queryAllUsers() {
        //对查询结果返回类型定义为List
        List<User> allusers = userMapper.queryAllUsers();
        return allusers;
    }

    @Override  //重写接口方法，根据ID查询该用户信息
    public User queryUserByID(int userID) {
        return userMapper.queryUserByID(userID);
    }

    @Override  //重写接口方法，增加用户数据
    public Boolean addUsers(User user) {
        return userMapper.addUsers(user);
    }

//    重写接口方法，修改用户密码
    @Override
    public Boolean updateUserPassword(int userID, String userpwd) {
        return null;
    }
//  重写接口方法，修改用户其他信息
    @Override
    public Boolean updateUsers(User user) {
        return userMapper.updateUsers(user);
    }


    @Override  //重写接口方法，删除用户数据
    public Boolean deleteUsers(int userID) {
        return userMapper.deleteUsers(userID);
    }


}
